//将秒转化为时分秒
export function systemDictApi(type) {
	if (uni.getStorageSync(`${type}List`)) {
		return
	}
	uni.$u.http.get(`/system/dict/data/type/${type}`).then(resData => {
		uni.setStorageSync(`${type}List`, resData.data);
	}).catch(err => {})
}
// 请求字典的多个方法
export function dictTypesApi(types) {
	// types.forEach((item, index) => {
	// 	if (uni.getStorageSync(`${item}List`)) {
	// 		types.splice(index, 1)
	// 	}
	// })
	let data = {
		types: types.toString()
	}
	uni.$u.http.post(`/system/dict/data/types`, data).then(resData => {
		types.forEach(item => {
			uni.setStorageSync(`${item}List`, resData.data[`${item}`]);
		})
	}).catch(err => {})
}
//数据字典
export function getDictLabel(str,num) {
	let dictList  = uni.getStorageSync(`${str}List`);
	let unitobj = dictList.find(item => item.dictValue == num);
	return unitobj.dictLabel
}
export default {
	systemDictApi,
	dictTypesApi,
	getDictLabel
}